﻿using System;
using EFEntity;
using ISerives;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Model;

namespace Serives
{
    public class UsersSerives : IUsersSerives
    {
        private readonly MyDbContext myDbContext;

        public UsersSerives(MyDbContext myDbContext)
        {
            this.myDbContext = myDbContext;
        }
        public async Task<int> Select(string name, string pass)
        {
            return await myDbContext.Users.Where(e => e.u_name == name && e.u_password == pass).CountAsync();
        
        }

        public async Task<Eusers> Select_Show(string name, string pass)
        {
            Eusers u = new Eusers();
            await Task.Run(() => {
                u=myDbContext.Users.Where(e => e.u_name == name && e.u_password == pass).FirstOrDefault();
            });
            return u;
        }
    }
}
